<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cli_task extends CI_Controller {
	public function __construct() {
		parent::__construct();
		if (!$this->input->is_cli_request()) {
			exit('Only CLI access allowed');
		}
	}
	
	/**
	 * 计算post的正常百分比
	 */
	public function proc_daily_hot_post() {
		//HOT_TYPE_DAILY
		$start_time = date('Y-m-d 00:00:00');
		$end_time = date('Y-m-d 23:59:59');
		log_message('debug', "计算当日({$start_time} ~ {$end_time})投票数最多的post，开始...");
		$this->load->model('post_model');
		$post_list = $this->post_model->get_top_by_time_range($start_time, $end_time, 10);
		if (!empty($post_list)) {
			
		}
		log_message('debug', "计算当日({$start_time} ~ {$end_time})投票数最多的post，结束！");
	}
	
	public function proc_weekly_hot_post() {
		//HOT_TYPE_WEEKLY
		$start_time = date('Y-m-d 00:00:00', strtotime('-1 week Monday'));
		$end_time = date('Y-m-d 23:59:59', strtotime('Sunday'));
		log_message('debug', "计算当周({$start_time} ~ {$end_time})投票数最多的post，开始...");
		$this->load->model('post_model');
		$post_list = $this->post_model->get_top_by_time_range($start_time, $end_time, 10);
		if (!empty($post_list)) {
			
		}
		log_message('debug', "计算当周({$start_time} ~ {$end_time})投票数最多的post，结束！");
	}
	
	public function proc_monthly_hot_post() {
		//HOT_TYPE_MONTHLY
		$days_in_month = date('t', time());
		$start_time = date('Y-m-01 00:00:00');
		$end_time = date("Y-m-{$days_in_month} 23:59:59");
		log_message('debug', "计算当月({$start_time} ~ {$end_time})投票数最多的post，开始...");
		$this->load->model('post_model');
		$post_list = $this->post_model->get_top_by_time_range($start_time, $end_time, 10);
		if (!empty($post_list)) {
			
		}
		log_message('debug', "计算当月({$start_time} ~ {$end_time})投票数最多的post，结束！");
	}
}